package com.hzhjhh.view.manageView.menus.purchase.purchaseOrder;

import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JOptionPane;

import org.apache.commons.lang3.StringUtils;

import com.hzhjhh.init.dialog.Mytable;
import com.hzhjhh.view.manageView.menus.purchase.PurchaseOrderDialog;
import com.hzhjhh.view.manageView.menus.purchase.constant.ShowConstants;

/**
 * 菜单栏初始化-采购-采购表弹出框-确定按钮
 * 
 * @author 12083
 *
 */
public class EnsureBt {

	/**
	 * 按钮
	 */
	public static JButton btInit(PurchaseOrderDialog stockDialog) {
		JButton ensure = new JButton();
		ensure.setBounds(137, 93, 83, 25);
		ensure.setText("确定");
		ensure.addActionListener(event -> {
			String txfMerchandiseCode = stockDialog.getTxfMerchandiseCode().getText();
			String txfPurchaseNum = stockDialog.getTxfPurchaseNum().getText();
//		String txf4 = stockDialog.getJTextField4().getText();
			String txfPaymentTerm = stockDialog.getTxfPaymentTerm().getText();
			if (StringUtils.isAnyBlank(txfMerchandiseCode, txfPurchaseNum, txfPaymentTerm)) {
	            JOptionPane.showMessageDialog(stockDialog, "请完整输入所有信息", "错误",
	                    JOptionPane.ERROR_MESSAGE);
	            return;
	        }
			Vector inserAll = stockDialog.getInserAll();
	        Vector insertone = new Vector();
	        insertone.add(txfMerchandiseCode);
	        insertone.add(stockDialog.getTxfMerchandiseName().getText());
	        insertone.add(stockDialog.getTxfPurchaseDept().getText());
	        insertone.add(txfPurchaseNum);
	        insertone.add(stockDialog.getTxfPricePerOne().getText());
	        insertone.add(stockDialog.getTxfAmt().getText());
	        insertone.add(stockDialog.getTxfOrderDate().getText());
	        insertone.add(txfPaymentTerm);
	        inserAll.add(insertone);
//	        jTable1 = Mytable.maketable(inserAll, colnames); //显示内容
	        stockDialog.setJTable1(Mytable.maketable(inserAll, ShowConstants.PURCHASE_HEAD_NAME));
	        stockDialog.getJScrollPane1().getViewport().add(stockDialog.getJTable1());
//	        jScrollPane1.getViewport().add(jTable1); //把表装入容器
		});
		return ensure;
	}
}
